<template>
  <view class="content">
    <cc-goback title='修改密码' color="#fff"></cc-goback>
    <view class="navigation_head">
    </view>
    <view class="password">
      <view class="word">
        旧密码
      </view>
      <input type="text" v-model="oldpassword" placeholder="请输入旧密码" />
    </view>
    <view class="password">
      <view class="word">
        新密码
      </view>
      <input type="text" v-model="newpassword" placeholder="请输入新密码" />
    </view>
    <view class="password">
      <view class="word">
        确认密码
      </view>
      <input type="text" v-model="confirmpassword" placeholder="确认新密码" />
    </view>
    <view class="btn">
      <button type="primary" @click="submit">提交</button>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        oldpassword: '',
        newpassword: '',
        confirmpassword: ''
      };
    },
    methods: {
      chuangepassword() {
        // console.log('this.newpassword', this.newpassword)
        // console.log('this.oldpassword', this.oldpassword)
        // console.log('this.confirmpassword', this.confirmpassword)
        this.$http.put('/upms/user/updateUserPassword', {
          confirmPassword: this.confirmpassword,
          newPassword: this.newpassword,
          oldPassword: this.oldpassword,
          type:1
        }).then(res => {
           console.log('res', res)
          if (res.code == '00000') {
            uni.showToast({
              	title: '修改密码成功',
              	icon: 'none',
              	duration: 2000
            })
            uni.removeStorageSync('token');
            uni.navigateTo({
              url: '../login/login'
            })
            // console.log('res', res)
            return
          }
          uni.showToast({
            	title: res.errorMsg,
            	icon: 'none',
            	duration: 2000
          })
        })
      },
      // 提交按钮
      submit() {
        this.chuangepassword()
      }
    }
  }
</script>

<style lang="scss">
  .navigation_head {
    height: calc(88rpx + var(--status-bar-height));
  }

  .password {
    display: flex;
    align-items: center;
    margin: 0 auto;
    width: 690rpx;
    height: 104rpx;
    border-bottom: 1rpx solid #E6E6E6;
  }

  .word {
    width: 120rpx;
    margin-right: 40rpx;
    font-size: 30rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #333333;
  }

  .btn {
    width: 702rpx;
    height: 80rpx;
    margin: 100rpx auto 0;
  }
</style>
